// 所有api接口统一管理
import requests from "./request";
import mockAjax from "./mockAjax";

export const reqCategoryList = () => requests({
    url: '/product/getBaseCategoryList',
    method: 'get'
})
export const reqDetail = (skuId = '') => requests({
    url: `/item/${skuId}`,
    method: 'get'
})
export const reqBanners = () => mockAjax({
    url: '/banners',
    method: 'get'
})
export const reqFloors = () => mockAjax({
    url: '/floors',
    method: 'get'
})

export const reqSearchList = (params = {}) => requests({
    url: '/list',
    method: 'post',
    data: params
})
export const reqAddCar = (skuId, skuNum) => requests({
        url: `/cart/addToCart/${skuId}/${skuNum}`,
        method: 'post'
})

export const reqCartList = (skuId, skuNum) => requests({
    url: `/cart/cartList`,
    method: 'get'
})

export const reqDeleteCart = (skuId) => requests({
    url: `/cart/deleteCart/${skuId}`,
    method: 'delete'
})

// /api/cart/checkCart/{skuID}/{isChecked}
export const reqChangeCheckedById = (skuId,isChecked) => requests({
    url: `/cart/checkCart/${skuId}/${isChecked}`,
    method: 'get'
})
// 获取验证码
export const reqRegCode = (phone) => requests({
    url: `/user/passport/sendCode/${phone}`,
    method: 'get'
})
// 完成注册
export const reqRegister = (data) => requests({
    url: `/user/passport/register`,
    method: 'post',
    data:data
})
// 完成登录
export const reqLogin = (data) => requests({
    url: `/user/passport/login`,
    method: 'post',
    data:data
})
// 获取用户信息

export const reqGetUserInfo = () => requests({
    url: `/user/passport/auth/getUserInfo`,
    method: 'get' 
})
// 退出登录
export const reqLogout= () => requests({
    url: `user/passport/logout`,
    method: 'get' 
})
// 获取用户地址信息
export const reqGetAddressList= () => requests({
    url: `/user/userAddress/auth/findUserAddressList`,
    method: 'get' 
})
// 获取我的订单
export const reqGetOrder= () => requests({
    url: `/order/auth/trade`,
    method: 'get' 
})
// 提交订单
export const reqCommitOrder= ({tradeNo,data}) => requests({
    url: `/order/auth/submitOrder?tradeNo=${tradeNo}`,
    method: 'post',
    data:data
})
// 获取订单支付信息 
export const reqGetPayment= (orderId) => requests({
    url: `/payment/weixin/createNative/${orderId}`,
    method: 'get'
})
// 查询支付情况 
export const reqGetPaymentResult= (orderId) => requests({
    url: `/payment/weixin/queryPayStatus/${orderId}`,
    method: 'get'
})
// 获取我的订单
export const reqGetMyOrder= ({page,limit}) => requests({
    url: `/order/auth/${page}/${limit}`,
    method: 'get'
})